/*
 * Copyright 2013 Glassy Cinema.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package hu.glassy.web.panel.common;

import hu.glassy.web.page.BaseWebPage;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Kiterjesztett panel, plusz funkciókkal.
 *
 * @author molnar.alexander@sonrisa.hu
 * @param <T>
 *            Modell objektum típusa
 */
public class CustomPanel<T> extends Panel
{

  private static final long serialVersionUID = 7678305943425921847L;
  protected Logger logger = LoggerFactory.getLogger(CustomPanel.class);

  /**
   * Konstruktor
   *
   * @param id
   */
  public CustomPanel(final String id)
  {
    this(id, null);
  }

  /**
   * Konstruktor
   *
   * @param id
   * @param model
   */
  public CustomPanel(final String id, final IModel<?> model)
  {
    super(id, model);
  }

  /**
   * Visszaadja a panelhez tartozó modellt.
   */
  @SuppressWarnings("unchecked")
  public IModel<T> getmainModel()
  {
    return (IModel<T>) getDefaultModel();
  }

  /**
   * Visszaadja a panelhez tartozó modell által hordozott objektumot.
   */
  @SuppressWarnings("unchecked")
  public T getMainObject()
  {
    return (T) getDefaultModelObject();
  }

  /**
   * Visszaadja a közös {@link BaseWebPage} interfészt
   */
  public BaseWebPage getMainPage()
  {
    return (BaseWebPage) getPage();
  }
}
